<%@ page import="com.zou.beans.Photo" %>
<%@ page import="com.zou.beans.User" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>照片上传</title>
    <link href="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/4.5.3/css/bootstrap.min.css" rel="stylesheet">
    <style>
        form span {
            display: inline-block;
            width: 95px;
            text-align: right
        }
        #main {
            margin: 100px auto;
            width: 500px;
            padding: 0 30px 30px 30px
        }
        body {
            background-image: url('./images/bg.jpg')
        }
    </style>
</head>
<body>
<%
    User user = (User) session.getAttribute("User");
    if (user == null) {
        response.sendRedirect("login.jsp");
    }

    Long id = 0L;
    String name = null;
    String url = null;
    try {
        id = Long.valueOf(request.getParameter("id"));
        name = request.getParameter("name");
        url = request.getParameter("url");
    } catch (Exception ignored) {
    }
    name = name == null ? "" : name;
    url = url == null ? "" : url;

%>
<!--顶部导航栏部分-->
<nav class="navbar navbar-dark sticky-top bg-success flex-md-nowrap p-0 shadow">
    <a class="navbar-brand col-md-3 col-lg-2 mr-0 px-3"
       href="https://blog.csdn.net/Zou_05">&emsp;&emsp;&emsp;小邹喜欢Java</a>
    <div class="btn-group" style="margin-right: 100px">
        当前用户：<%=user.getName()%>
    </div>
</nav>
<div id="main">

    <div align="center">
        <h3>图片上传</h3>
    </div>

    <form action="EditPhotoServlet" align="center" method="post">
        <input type="hidden" name="PhotoId" value="<%=id%>"/><br>
        <div class="input-group mb-3">
            <span class="input-group-text" id="basic-addon1">图片描述：</span>
            <input type="text" class="form-control" name="PhotoName" value="<%=name%>" placeholder="请在.jpg前面输入01-100的数字！" aria-describedby="basic-addon1">
        </div>
        <%
            if (url.equals("")) {
                //新增时设置默认值
                url = "http://47.100.15.29/img/01.jpg";
            }
        %>
        <div class="input-group mb-3">
            <span class="input-group-text" id="basic-addon2">图片地址：</span>
            <input type="text" name="PhotoUrl" value="<%=url%>" class="form-control" aria-label="Username" aria-describedby="basic-addon2">
        </div>
        <input class="btn btn-outline-primary" type="submit" value="提交">
        <a class="btn btn-outline-info" href="javascript:history.go(-1);">取消</a>
    </form>

</div>

</body>
</html>
